package com.google.sky.ai.simple;

/**
 * Target position with heuristic score of such move.
 * Move with the higher score is better for "mine", with lower - for "not mine".
 *
 * @author sslautin
 * @version 1.0 22.11.2014
 */
public class ScoredMove implements Comparable<ScoredMove> {

    public final int x;
    public final int y;
    public final boolean mine;

    private int score = 0;

    public ScoredMove(int x, int y, boolean mine) {
        this.x = x;
        this.y = y;
        this.mine = mine;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public int compareTo(ScoredMove otherMove) {

        if (otherMove == null) {
            return 1;
        }

        if (mine) {
            if (score < otherMove.score) {
                return -1;
            } else if (score == otherMove.score) {
                return 0;
            } else {
                return 1;
            }
        } else {
            if (score < otherMove.score) {
                return 1;
            } else if (score == otherMove.score) {
                return 0;
            } else {
                return -1;
            }
        }
    }
}
